<%@ codepage=65001%>
<!-- #include file="conn.asp" -->
<%
Session.CodePage=65001
Response.Charset="utf-8"

sType = request("sType")

if (IsEmpty(request("id")) or request("id")="" ) then
	id=0
else
	id=cint(trim(request("id")))
end if

userId=request("userId")
state=request("state")
userName=request("userName")
info=request("uploadPositionTextarea")
lng = request("lng")
lat = request("lat")

if sType = "add" then
	'on error resume next
	set rs= server.createobject("adodb.recordset")
	if id>0 then    'update
		sql="update [uploadPositionData] set [userId]='"&userId&"',[userName]='"&userName&"',[info]='"&info&"',[state]='"&state&"',[lng]='"&lng&"',[lat]='"&lat&"',[v1]='0' where id="&id
		conn.execute(sql)
		'sql="delete from userInfo where id="&id
		'conn.execute(sql)
		'sql="insert into userInfo ([username],[password],[p]) values ('"&username&"','"&password&"','"&p&"')"
		'conn.execute(sql)
		if err.number=0 then
			response.write "true"
		else
			response.write "false"
		end if
	else
		'sqlstr = "select count(*) as cc from uploadPositionData where wangdianName='"&wangdianName&"'"
		'rs.open sqlstr,conn,1,1
		'if rs("cc") = 0 then
			sql="insert into uploadPositionData ([userId],[userName],[info],[state],[lng],[lat],[dateTime],[v1]) values ('"&userId&"','"&userName&"','"&info&"','"&state&"','"&lng&"','"&lat&"','"&now()&"','0')"
			conn.execute(sql)
			if err.number=0 then
				response.write "true"
			else
				response.write "false"
			end if
		'else
		'	response.write "false"
		'end if
	end if
elseif sType = "del" then
	arrvalue=split(id,",")
    for i=0 to ubound(arrvalue)
      	on error resume next
	  	sql="delete from uploadPositionData where id=" & arrvalue(i)
		conn.execute(sql)
    next
else
end if

conn.close

%>